<?php header("Content-Type:text/html;   charset=utf-8"); ?>
<script type="text/javascript">
	$(function(){
		loadUserGroup();
		$("#hrefAddUserGroup").bind("click",addUserGroup);
		$("#hrefDelUserGroup").bind("click",delSelectUserGruop);
		$("#btnQueryUserGroup").bind("click",loadUserGroup);
	});
	function addUserGroup(){
		$("#hrefEditUserGroup").attr("href","admin.php/manage/newUserGroup");
		$("#hrefEditUserGroup").trigger("click");
	}
 	function delSelectUserGruop(){
 	 	var selIds=getSelectIdsUserGroup();
 	 	if(selIds==""){
 	 	 	alert('请选择要删除的项');
 	 	 	return;
 	 	}
 	 	if(confirm('删除后不可恢复，确认要删除吗？')==false)
 	 	 	return;
 	 	var params={id:selIds};
 	 	var url="admin.php/manage/delUserGroup";
 	 	$.ajax({
 	 	 	type:"post",
 	 	 	url:url,
 	 	 	dataType:"json",
 	 	 	data:params,
 	 	 	success:function(data){
				if(data.ReturnCode=="1"){
					loadUserGroup();
					alert('删除成功');
				}else{
					alert('删除失败');
				}
 	 	 	}
 	 	});
 	}
 	
	function getSelectIdsUserGroup(){
		var sel = "";
		$("#tableUserGroup td :checkbox:checked").each(function(){
			sel+=$(this).val()+",";
		});
		return sel;
	}
	function loadUserGroup(){
		$("#chkSelectAllUserGroup").attr("checked",false);
		var params = {
					name:$("#txtUserGroup").val()
				};		
		var url="admin.php/manage/loadUserGroup";
		$.ajax({
			type:"post",
			url:url,
			dataType:"html",
			data:params,
			success:function(data){
				$("#tableUserGroup").html(data);
				bindSelect("chkSelectAllUserGroup","tableUserGroup");				
			}
		});	
	}
	function modifyUserGroup(id){		
		$("#hrefEditUserGroup").attr("href","admin.php/manage/newUserGroup?id="+id);
		$("#hrefEditUserGroup").trigger("click");
	}
	
	function delUserGroup(id){
		if(confirm('删除后不可恢复，确定要继续删除吗？')){
			var params = {id:id};
			var url="admin.php/manage/delUserGroup";			
			$.ajax({
				type:"post",
				url:url,
				dataType:"json",
				data:params,
				success:function(data){										
					if(data.ReturnCode=="1"){
						loadUserGroup();
						alert('删除成功');
					}else{
						alert('删除失败');
					}
				}
			});
		}
	}	
</script>

<div class="pageHeader">
	<form>
		<div class="searchBar">
			<table class="searchContent">
				<tr>
					<td>用户组名称：<input type="text" id="txtUserGroup" />
					</td>

					<td>
						<div class="subBar">
							<ul>
								<li><div class="buttonActive">
										<div class="buttonContent">
											<button id="btnQueryUserGroup" type="button"
												style="width: 100px">查&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;询</button>
										</div>
									</div></li>
							</ul>
						</div>
					</td>
				</tr>
			</table>

		</div>
	</form>
</div>
<div class="pageContent">
	<div class="panelBar">
		<ul class="toolBar">
			<li style="display: none"><a id="hrefEditUserGroup" class="edit"
				href="" lookupgroup="orgLookup"><span>修改</span></a></li>
			<li><a id="hrefAddUserGroup" class="add" href="javascript:void(0)"><span>新建用户组</span></a></li>
			<li><a id="hrefDelUserGroup" class="delete" href="javascript:void(0)"><span>删除</span></a></li>
		</ul>
	</div>
	<table class="table" width="100%" layoutH="138">
		<thead>
			<tr>
				<th style='width: 30px; text-align: center;'><input type='checkbox'
					id='chkSelectAllUserGroup' /></th>
				<th style='width: 300px'>组名称</th>
				<th style='width: 260px'>操作</th>

			</tr>
		</thead>
		<tbody id="tableUserGroup">

		</tbody>
	</table>
</div>





























